<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Allocator Data Management</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
		//分摊域分摊公共参数
		var infoSort = "<s:property value='infoSort' />";
		var shareAreaUID = "<s:property value='shareAreaUID' />";
		var illegalIDList = "<s:property value='illegalIDList' />";
		//分配表数据
		var assignMeterUID = "<s:property value='assignMeter.id' />";
		var seriousNum = "<s:property escape='false' value='assignMeter.seriousNum' />";
		var readTime = "<s:date name='readTime' format='yyyy-MM-dd' nice='false' />";
		var meterDataUID = "<s:property value='meterDataUID' />";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
	<meta http-equiv="description" content="This is my page" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<script type="text/javascript" src="<%=basePath%>resources/jquery/jquery-1.7.2.min.js"></script>
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 表单校验 -->
	<jsp:include page="/resources/resource-refer/component-validform-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function submitForm() {
  		var meterDataUID = "<s:property value='meterDataUID' />";
  		//读数
  		var readNum = $("input[name='readNum']").val();
  		//背板温度
  		var backTmperature = $("input[name='backTmperature']").val();
  		//前板温度
  		var fontTemperature = $("input[name='fontTemperature']").val();
  		$.getJSON(path+"beshs/shareAreaResultActionJson!saveOrUpdateMeterData.do?date="+new Date(), {
  			"meterDataUID": meterDataUID,
  			"seriousNum": seriousNum,
  			"readNum": readNum,
  			"readTime": readTime,
  			"backTmperature": backTmperature,
  			"fontTemperature": fontTemperature,
  			//分摊域分摊信息
  			"infoSort": infoSort,
  			"illegalIDList": illegalIDList
  		}, function(data){
  			if(data.success) {
  				illegalIDList = data.msg; //不提示已更正的数据
  				Dialog.alert("Successful Operation！", function() {
  					var index = parent.layer.getFrameIndex(window.name)
					parent.window.frames["infoVeriPage"].location = path + "beshs/shareAreaResultAction!queryAreaResultInfoListBySort.do?infoSort=assignMeterData" 
							+ "&shareAreaUID=" + shareAreaUID
							+ "&illegalIDList=" + illegalIDList
							+ "&date="+ new Date();
  					parent.layer.close(index);
  				});
  			} else {
  				Dialog.alert("System error, please contact adminitrator！");
  			}
  		});
  	}
  	
  	$(function(){
		$("form[name='assignMeterDataForm']").Validform({
			btnSubmit: "input[name='submit']",
			btnReset: "input[name='reset']",
			tiptype: function(msg, o, cssctl){
				//msg：提示信息;
				//o:{obj:*,type:*,curform:*}, obj指向的是当前验证的表单元素（或表单对象），type指示提示的状态，值为1、2、3、4， 1：正在检测/提交数据，2：通过验证，3：验证失败，4：提示ignore状态, curform为当前form对象;
				//cssctl:内置的提示信息样式控制函数，该函数需传入两个参数：显示提示信息的对象 和 当前提示的状态（既形参o中的type）;
				if(!o.obj.is("form")){//验证表单元素时o.obj为该表单元素，全部验证通过提交表单时o.obj为该表单对象;
					var objtip=o.obj.siblings(".Validform_checktip");
					cssctl(objtip,o.type);
					objtip.text(msg);
				} else {
					var objtip=o.obj.find("#msgdemo");
					cssctl(objtip,o.type);
					objtip.text(msg);
				}
			},
			postonce: true, //开启二次提交防御，在数据成功提交后，表单将不能再继续提交
			showAllError: true, //提交表单时所有错误提示信息都会显示
			ajaxPost:true,
			beforeSubmit: function(curform) { //在验证成功后，表单提交前执行的函数，curform参数是当前表单对象
				submitForm();
				return true; //这里明确return false的话表单将不会提交
			}
		});
  	});
  </script>
  <body>
    <div class="content_all">
  		<!--导航条-->
  		<div class="insertinfo_table">
      		<form action="#" name="assignMeterDataForm"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      			<tr>
          			<th>Project：</th>
          			<td>
          				<s:property value='project.projectName' />
          			</td>
            		<th>District：</th>
          			<td>
          				<s:property value='community.communityName' />
          			</td>
        		</tr>
        		<tr>
          			<th>Building：</th>
          			<td>
          				<s:property value='building.buildingName' />
          			</td>
            		<th>Heat User：</th>
          			<td>
          				<s:property value='heatRoom.houseNo' />(<s:property value='heatRoom.roomOwner' />)
          			</td>
        		</tr>
        		<tr>
            		<th>Allocator No.：</th>
          			<td>
          				<s:property value='assignMeter.seriousNum' />
          			</td>
          			<th>Upload Time：</th>
          			<td>
          				<s:date name='readTime' format='yyyy-MM-dd HH:mm:ss' nice='false' />
          			</td>
        		</tr>
        		<tr>
          			<th>Readings：</th>
          			<td><input name="readNum" type="text" class="s_input" value="<s:property value='meterData.readNum' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Readings Verification Passed！" nullmsg="Please enter Readings！" errormsg="Please enter integral or float type value！" />
            			&nbsp;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter integral or float type value！</div></td>
            		<th>Rear Board Temperature：</th>
          			<td><input name="backTmperature" type="text" class="s_input" value="<s:property value='meterData.backTmperature' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Rear Board Temperature Verification Passed！" nullmsg="Please enter Rear Board Temperature！" errormsg="Please enter integral or float type value！"/>
            			&nbsp;&#8451;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter integral or float type value！</div></td>
        		</tr>
        		<tr>
        			<th>Front Board Temperature：</th>
          			<td><input name="fontTemperature" type="text" class="s_input" value="<s:property value='meterData.fontTemperature' />" 
          					datatype="n1-10|/^([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$/" sucmsg="Front Board Temperature Verification Passed！" nullmsg="Please enter Front Board Temperature！" errormsg="Please enter integral or float type value！"/>
            			&nbsp;&#8451;<span style="color:#FF0000;">*</span>
            			<div class="Validform_checktip">Please enter integral or float type value！</div></td>
            		<th></th>
          			<td></td>
        		</tr>
        		<tr>
          			<td style="border:none;" colspan="4" align="center">
          				<input name="submit" type="button" value="Submit" class="s_btn" />
            			<input name="reset" type="reset" value="Reset" class="s_btn"/></td>
        		</tr>
      		</table></form>
  		</div>
	</div>
	<div class="clear"></div>
	<table cellpadding="0" class="frame_right" cellspacing="0" border="0" height="100%" width="100%">
  		<tr>
  			<td>
  			<!-- 根据校验信息类别导航对应的更正页面 -->
  				<script type="text/javascript">
  					$(function() {
  						window.frames["historyData"].location = path + "beshs/shareAreaResultAction!queryHistoryMeterData.do?infoSort=assignMeterData" 
								+ "&seriousNum=" + encodeURIComponent(seriousNum)
								+ "&readTime=" + readTime
								+ "&date=" + new Date();
  					});
  				</script>
  				<iframe frameborder="0" scrolling="auto" name="historyData" id="historyData" src="<%=basePath%>common/empty.jsp" height="100%" width="100%"></iframe>
  			</td>
  		</tr>
  	</table>
  </body>
</html>
